<template>
  <el-upload v-model:file-list="fileList" :action="uploadUrl" :on-success="success"
  list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
    <el-icon><Plus /></el-icon>
  </el-upload>

  <el-dialog v-model="dialogVisible">
    <img w-full :src="dialogImageUrl" alt="Preview Image" />
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue'
import { Plus } from '@element-plus/icons-vue'
// import { UploadProps, UploadUserFile } from 'element-plus'
import {uploadUrl,host} from '@/api/product'
const emit= defineEmits(['sendImgUrl'])
// const props = defineProps(['fileList'])

const fileList = ref([
  
])


const dialogVisible = ref(false)

const handleRemove= (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles)
}

const success = (response) => {
  console.log('response',response);
  //需要获取正确的网址 访问这个图片  发送给添加商品接口 img地址
    let url = host+'/'+ response.url.slice(7)
    console.log(url);
    emit('sendImgUrl',url)
}
</script>

<style>
</style>